#include <bits/stdc++.h>
#include <cstdio>
#include <string>
using namespace std;
#define ll long long
#define XH(i,a,b) for(int i = a; i < b; ++i)
#define XXH(i,b,a) for(int i = b; i >= a; --i)
#define Module 998244353
int tInt;ll tll;string tString;char tChar;
vector<int>tIVector;

string s1,s2,s3;
int a[127];
int aa[127];
int b[50];
int cnt = 0;
int ok = 1;
int dfsok = 0;
int myvisit[20] = {0};

ll mystoi(string s){
  ll ret = 0;
  XH(i,0,s.size()){
    if(i == 0 && aa[s[i]] == 0) return -1;
    ret = ret * 10 + aa[s[i]];
  }
  return ret;
}

void judge(){
  ll x=mystoi(s1),y=mystoi(s2),z=mystoi(s3);
  if(x + y == z && x!=-1 && y!=-1 && z!=-1){
    printf("%lld\n%lld\n%lld\n",x,y,z);
    dfsok = 1;
  }
}

void dfs(int level){
  if(dfsok)return;
  if(level == cnt){
    judge();
    return;
  }
  XH(i,0,10){
    if(myvisit[i] == 0){
      int index = b[level];
      aa[index] = i;
      /* cout<<"level="<<level<<" aa[index]="<<aa[index]<<" index"<<index<<endl; */
      myvisit[i] = 1;
      dfs(level + 1);
      myvisit[i] = 0;
    }
  }
}

void solve(){
  /* cout<<"cnt="<<cnt<<endl; */
  if(cnt > 10){
    ok = 0;
  }else{
    dfs(0);
    if(!dfsok){
      ok = 0;
    }
  }
  if(ok == 0)printf("UNSOLVABLE\n");
}

void init(string s){
  XH(i,0,s.size()){
    if(a[s[i]] == 0){
      a[s[i]] = 1;
      b[cnt] = s[i];
      cnt++;
    }
  }
}

int main(){
  #ifndef ONLINE_JUDGE
    auto start_clock = clock();
    /* freopen("input.txt","r",stdin); */
    /* freopen("output.txt","w",stdout); */
  #endif
  cin>>s1>>s2>>s3;
  init(s1);
  init(s2);
  init(s3);
  solve();
  
  #ifndef ONLINE_JUDGE
    auto end_clock = clock();
    //cout<<"runtime: "<<end_clock - start_clock<<"ms"<<endl;
  #endif
  return 0;
}
